package nancal.mp.service.jenkins

interface JenkinsScript {

    fun getLibJenkinsPipeLine(): String

    fun getNativeJenkinsPipeLine(): String

    fun getDockerJenkinsPipeLine(): String

    fun getK8sJenkinsPipeLine(): String


    fun genStage(name: String, content: String): String


    fun getCodeStage(): String {
        return genStage("下载代码", """get-code""")
    }


    fun getCompileStage(): String {
        return genStage(
            "编译构建", """
# run-in-docker show-path
docker-build
"""
        )
    }

    fun getPushState(hasHarbor: Boolean):String{
        if (!hasHarbor) {
            return "";
        }
        return genStage(
            "推送镜像", """
docker-push
"""
        )
    }


    fun unzipDockerTar(hasHarbor: Boolean): String {
        if (hasHarbor) {
            return "";
        }

        return genStage(
            "DockerImage提取", """
peek-from-docker
run-in-docker unzip-docker-tar
"""
        )
    }
}